home *** CD-ROM | disk | FTP | other *** search
- Frequently Asked Questions (FAQS);faqs.386
-
-
-
- Some good general references are {Advanced MS-DOS} by Ray Duncan,
- ISBN 1-55615-157-8; {8088 Assembler Language Programming: The IBM
- PC}, ISBN 0-672-22024-5, by Willen & Krantz; and {COMPUTE!'s Mapping
- the IBM PC}, ISBN 0-942386-92-2.
-
- Q304. How can I disable the print screen function?
-
- There are really two print screen functions: 1) print current
- screen snapshot, triggered by PrintScreen or Shift-PrtSc or
- Shift-grey*, and 2) turn on continuous screen echo, started and
- stopped by Ctrl-P or Ctrl-PrtSc.
-
- 1) Screen snapshot to printer
- --------------------------
-
- The BIOS uses INT 5 for this. Fortunately, you don't need to mess
- with that interrupt handler. The standard handler, in BIOSes dated
- December 1982 or later, uses a byte at 0040:0100 (alias 0000:0500)
- to determine whether a print screen is currently in progress. If it
- is, pressing PrintScreen again is ignored. So to disable the screen
- snapshot, all you have to do is write a 1 to that byte. When the
- user presses PrintScreen, the BIOS will think that a print screen is
- already in progress and will ignore the user's keypress. You can
- re-enable PrintScreen by zeroing the same byte.
-
- Here's some simple code:
-
- void prtsc_allow(int allow) /* 0=disable, nonzero=enable */ {
- unsigned char far* flag = (unsigned char far*)0x00400100UL;
- *flag = (unsigned char)!allow;
- }
-
- 2) Continuous echo of screen to printer
- ------------------------------------
-
- If ANSI.SYS is loaded, you can easily disable the continuous echo of
- screen to printer (Ctrl-P or Ctrl-PrtSc). Just redefine the keys by
- "printing" strings like these to the screen (BASIC print, C printf,
- Pascal Write statements, or ECHO command in batch files):
-
- <27>[0;114;"Ctrl-PrtSc disabled"p
- <27>[16;"^P"p
-
- Change <27> in the above to an Escape character, ASCII 27.
-
- If you haven't installed ANSI.SYS, I can't offer an easy way to
- disable the echo-screen-to-printer function. Please send any tested
- solutions to brown@ncoast.org and I'll add them to this list.
-
- Actually, you might not need to disable Ctrl-P and Ctrl-PrtSc. If
- your only concern is not locking up your machine, when you see the
- "Abort, Retry, Ignore, Fail" prompt just press Ctrl-P again and then
- I. As an alternative, install one of the many print spoolers that
- intercept printer-status queries and always return "Printer ready".
-
- Q305. How can my program turn NumLock (CapsLock, ScrollLock) on or off?
-
- You need to twiddle bit 5, 6, or 4 of location 0040:0017. Here's
- some code: lck( ) turns on a lock state, and unlck( ) turns it off.
- (The status lights on some keyboards may not reflect the change. If
- yours is one, call INT 16 function 2, "get shift status", and that
- may update them. It will certainly do no harm.)
-
- #define NUM_LOCK (1 << 5)
- #define CAPS_LOCK (1 << 6)
- #define SCRL_LOCK (1 << 4)
- void lck(int shiftype) {
- char far* kbdstatus = (char far*)0x00400017UL;
- *kbdstatus |= (char)shiftype;
- }
- void unlck(int shiftype) {
- char far* kbdstatus = (char far*)0x00400017UL;
- *kbdstatus &= ~(char)shiftype;
- }
-
- Q306. How can I speed up the keyboard's auto-repeat?
-
- The keyboard speed has two components: delay (before a key that you
- hold down starts repeating) and typematic rate (the speed once the
- key starts repeating). Most BIOSes since 1986 let software change
- the delay and typematic rate by calling INT 16 function 3, "set
- typematic rate and delay"; see Ralf Brown's interrupt list. If you
- have DOS 4.0 or later, you can use the MODE CON command that you'll
- find in your DOS manual.
-
- On 83-key keyboards (mostly XTs), the delay and typematic rate can't
- easily be changed. According to the {PC Magazine} of 15 Jan 1991,
- page 409, to adjust the typematic rate you need "a memory-resident
- program which simply '[watches]' the keyboard to see if you're
- holding down a key ... and after a certain time [starts] stuffing
- extra copies of the held-down key into the buffer." No source code
- is given in that issue; but I'm told that the QUICKEYS utility that
- {PC} published in 1986 does this sort of watching; you can download
- source and object code in PD1:<MSDOS.PCMAG>VOL5N05.ARC from Simtel.
-
- Q307. What is the SysRq key for?
-
- There is no standard use for the key. The BIOS keyboard routines in
- INT 16 simply ignore it; therefore so do the DOS input routines in
- INT 21 as well as the keyboard routines in libraries supplied with
- high-level languages.
-
- When you press or release a key, the keyboard triggers hardware line
- IRQ1, and the CPU calls INT 9. INT 9 reads the scan code from the
- keyboard and the shift states from the BIOS data area.
-
- What happens next depends on whether your PC's BIOS supports an
- enhanced keyboard (101 or 102 keys). If so, INT 9 calls INT 15
- function 4F to translate the scan code. If the translated scan code
- is 54 hex (for the SysRq key) then INT 9 calls INT 15 function 85
- and doesn't put the keystroke into the keyboard buffer. The default
- handler of that function does nothing and simply returns. (If your
- PC has an older BIOS that doesn't support the extended keyboards,
- INT 15 function 4F is not called. Early ATs have 84-key keyboards,
- so their BIOS calls INT 15 function 85 but nor 4F.)
-
- Thus your program is free to use SysRq for its own purposes, but at
- the cost of some programming. You could hook INT 9, but it's
- probably easier to hook INT 15 function 85, which is called when
- SysRq is pressed or released.
-
- Q308. How can my program tell what kind of keyboard is on the system?
-
- Ralf Brown's Interrupt List includes MEMORY.LST, a detailed
- breakdown by Robin Walker of the contents of the BIOS system block
- that starts at 0040:0000. Bit 4 of byte 0040:0096 is "1=enhanced
- keyboard installed". C code to test the keyboard type:
- char far *kbd_stat_byte3 = (char far *)0x00400096UL;
- if (0x10 & *kbd_stat_byte3)
- /* 101- or 102-key keyboard is installed */
-
- {PC Magazine}'s 15 Jan 1991 issue suggests on page 412 that "for
- some clones [the above test] is not foolproof". If you use this
- method in your program you should provide the user some way to
- override this test, or at least some way to tell your program to
- assume a non-enhanced keyboard. The {PC Magazine} article suggests
- a different approach to determining the type of keyboard.
-
- Q309. How can I tell if input, output, or stderr has been redirected?
-
- Normally, input and output are associated with the console (i.e.,
- with the keyboard and the screen, respectively). If either is not,
- you know that it has been redirected. Some source code to check
- this is available at the usual archive sites.
-
- If you program in Turbo Pascal, download the /pc/ts/tspa*.zip
- collection of Turbo Pascal units from garbo; or from Simtel,
- PD1:<MSDOS.TURBOPAS>TSPA*.ZIP. (Choose TSPA3060.ZIP, TSPA3055.ZIP,
- TSPA3050.ZIP, or TSPA3040.ZIP for Turbo Pascal 6.0, 5.5, 5.0, or 4.0
- respectively.) Source code is not included. Also see the
- information in garbo.uwasa.fi:/pc/ts/tsfaq*.zip Frequently Asked
- Questions, the Turbo Pascal section.
-
- If you program in C, use isatty( ) if your implementation has it.
- Otherwise, you can download PD1:<MSDOS.SYSUTL>IS_CON10.ZIP from
- Simtel; it includes source code.
-
- Good references for the principles are {PC Magazine} 16 Apr 1991
- (vol 10 nr 7) pg 374; Ray Duncan's {Advanced MS-DOS}, ISBN
- 1-55615-157-8, or Ralf Brown's interrupt list for INT 21 function
- 4400; and Terry Dettman and Jim Kyle's {DOS Programmer's Reference:
- 2d edition}, ISBN 0-88022-458-4, pp 602-603.
-
- (continued in part 3)
- --
- Stan Brown, Oak Road Systems brown@Ncoast.ORG
- Cleveland, Ohio, USA
- Xref: bloom-picayune.mit.edu comp.os.msdos.programmer:18890 news.answers:4713
- Path: bloom-picayune.mit.edu!enterpoop.mit.edu!eru.mt.luth.se!lunic!sunic!mcsun!uknet!doc.ic.ac.uk!agate!ames!sun-barr!cs.utexas.edu!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!ncoast!brown
- From: brown@NCoast.ORG (Stan Brown)
- Newsgroups: comp.os.msdos.programmer,news.answers
- Subject: comp.os.msdos.programmer FAQ part 3 of 4
- Message-ID: <msdos-faq.921220.3@NCoast.ORG>
- Date: 20 Dec 92 20:14:13 GMT
- Expires: Wed, 3 Feb 1993 20:14:13 GMT
- References: <msdos-faq.921220.1@NCoast.ORG>
- Followup-To: comp.os.msdos.programmer
- Organization: Oak Road Systems, Cleveland Ohio USA
- Lines: 898
- Approved: news-answers-request@MIT.Edu
- Supersedes: <msdos-faq.921205.3@NCoast.ORG>
-
- Archive-name: msdos-programmer-faq/part3
- Last-modified: 20 December 1922
-
-
- (continued from part 2) (no warranty on the code or information)
-
- If the posting date is more than six weeks in the past, see instructions
- in part 4 of this list for how to get an updated copy.
-
- Copyright (C) 1992 Stan Brown, Oak Road Systems
-
-
- section 4. Disks and files
- ===========================
-
- Q401. What drive was the PC booted from?
-
- Under DOS 4.0 or later, load 3305 hex into AX; do an INT 21. DL is
- returned with an integer indicating the boot drive (1=A:, etc.).
-
- Q402. How can I boot from drive b:?
-
- Download PD1:<MSDOS.DSKUTL>BOOT_B.ZIP (shareware) from Simtel. The
- included documentation says it works by writing a new boot sector on
- a disk in your a: drive that redirects the boot to your b: drive.
-
- Q403. Which real and virtual disk drives are valid?
-
- Use INT 21 function 29 (parse filename). Point DS:SI at a null-
- terminated ASCII string that contains the drive letter and a colon,
- point ES:DI at a 37-byte dummy FCB buffer, set AX to 2900h, and do
- an INT 21. On return, AL is FF if the drive is invalid, something
- else if the drive is valid. RAM disks and SUBSTed drives are
- considered valid.
-
- Unfortunately, the b: drive is considered valid even on a single-
- diskette system. You can check that special case by interrogating
- the BIOS equipment byte at 0040:0010. Bits 7-6 contain the one less
- than the number of diskette drives, so if those bits are zero you
- know that b: is an invalid drive even though function 29 says it's
- valid.
-
- Following is some code originally posted by Doug Dougherty, with my
- fix for the b: special case, tested only in Borland C++ 2.0 (in
- the small model):
-
- #include <dos.h>
- void drvlist(void) {
- char *s = "A:", fcb_buff[37];
- int valid;
- for ( ; *s<='Z'; (*s)++) {
- _SI = (unsigned) s;
- _DI = (unsigned) fcb_buff;
- _ES = _DS;
- _AX = 0x2900;
- geninterrupt(0x21);
- valid = _AL != 0xFF;
- if (*s == 'B' && valid) {
- char far *equipbyte = (char far *)0x00400010UL;
- valid = (*equipbyte & (3 << 6)) != 0;
- }
- printf("Drive '%s' is %sa valid drive.\n",
- s, valid ? "" : "not ");
- }
- }
-
- Q404. How can I make my single floppy drive both a: and b:?
-
- Under any DOS since DOS 2.0, you can put the command
-
- assign b=a
-
- into your AUTOEXEC.BAT file. Then, when you type "DIR B:" you'll no
- longer get the annoying prompt to insert diskette B (and the even
- more annoying prompt to insert A the next time you type "DIR A:").
-
- You may be wondering why anybody would want to do this. Suppose you
- use two different machines, maybe one at home and one at work. One
- of them has only a 3.5" diskette drive; the other machine has two
- drives, and b: is the 3.5" one. You're bound to type "dir b:" on
- the first one, and get the nuisance message
-
- Insert diskette for drive B: and press any key when ready.
-
- But if you assign drive b: to point to a:, you avoid this problem.
-
- Caution: there are a few commands, such as DISKCOPY, that will not
- work right on ASSIGNed or SUBSTed drives. See the DOS manual for
- the full list. Before typing one of those commands, be sure to turn
- off the mapping by typing "assign" without arguments.
-
- The DOS 5.0 manual says that ASSIGN is obsolete, and recommends the
- equivalent form of SUBST: "subst b: a:\". Unfortunately, if this
- command is executed when a: doesn't hold a diskette, the command
- fails. ASSIGN doesn't have this problem, so I must advise you to
- disregard that particular bit of advice in the DOS manual.
-
- Q405. Why won't my C program open a file with a path?
-
- You've probably got something like the following code:
-
- char *filename = "c:\foo\bar\mumble.dat";
- . . . fopen(filename, "r");
-
- The problem is that \f is a form feed, \b is a backspace, and \m is
- m. Whenever you want a backslash in a string constant in C, you
- must use two backslashes:
-
- char *filename = "c:\\foo\\bar\\mumble.dat";
-
- This is a feature of every C compiler, because Dennis Ritchie
- designed C this way. It's a problem only on MS-DOS systems, because
- only DOS (and Atari ST/TT running TOS, I'm told) uses the backslash
- in directory paths. But even in DOS this backslash convention
- applies _only_ to string constants in your source code. For file
- and keyboard input at run time, \ is just a normal character, so
- users of your program would type in file specs at run time the same
- way as in DOS commands, with single backslashes.
-
- Another possibility is to code all paths in source programs with /
- rather than \ characters:
-
- char *filename = "c:/foo/bar/mumble.dat";
-
- Ralf Brown writes that "All versions of the DOS kernel accept either
- forward or backslashes as directory separators. I tend to use this
- form more frequently than backslashes since it is easier to type and
- read." This applies to DOS function calls (and therefore to calls
- to the file library of every programming language), but not to DOS
- commands.
-
- Q406. How can I redirect printer output to a file?
-
- My personal favorite utility for this purpose is PRN2FILE from {PC
- Magazine}, available from Simtel as PD1:<MSDOS.PRINTER>PRN2FILE.ARC,
- or from garbo as prn2file.zip in /pc/printer. ({PC Magazine} has
- given copies away as part of its utilities disks, so you may already
- have a copy.)
-
- Check the PD1:<MSDOS.PRINTER> directory at Simtel, or /pc/printer
- at garbo, for lots of other printer-redirection utilities.
-
- Q407. How can my program open more files than DOS's limit of 20?
-
- (This is a summary of an article Ralf Brown posted on 8 August 1992.)
-
- There are separate limits on files and file handles. For example,
- DOS opens three files but five file handles: CON (stdin, stdout,
- and stderr), AUX (stdaux), and PRN (stdprn).
-
- The limit in FILES= in CONFIG.SYS is a system-wide limit on files
- opened by all programs (including the three that DOS opens and any
- opened by TSRs); each process has a limit of 20 handles (including
- the five that DOS opens). Example: CONFIG.SYS has FILES=40. Then
- program #1 will be able to open 15 file handles. Assuming that the
- program actually does open 15 handles pointing to 15 different
- files, other programs could still open a total of 22 files (40-3-15
- = 22), though no one program could open more than 15 file handles.
-
- If you're running DOS 3.3 or later, you can increase the per-process
- limit of 20 file handles by a call to INT 21 function 67, Set Handle
- Count. Your program is still limited by the system-wide limit on
- open files, so you may also need to increase the FILES= value in
- your CONFIG.SYS file (and reboot). The run-time library that you're
- using may have a fixed-size table of file handles, so you may also
- need to get source code for the module that contains the table,
- increase the table size, and recompile it.
-
- Q408. How can I read, create, change, or delete the volume label?
-
- In DOS 5.0 (and, I believe, in 4.0 as well), there are actually two
- volume labels: one, the traditional one, is an entry in the root
- directory of the disk; and the other is in the boot record along
- with the serial number (see next Q). The DIR and VOL commands
- report the traditional label; the LABEL command reports the
- traditional one but changes both of them.
-
- In DOS 4.0 and later, use INT 21 function 69 to access the boot
- record's serial number and volume label together; see the next Q.
-
- Assume that by "volume label" you mean the traditional one, the one
- that DIR and VOL display. Though it's a directory entry in the root
- directory, you can't change it using the newer DOS file-access
- functions (3C, 41, 43); instead, use the old FCB-oriented directory
- functions. Specifically, you need to allocate a 64-byte buffer and
- a 41- byte extended FCB (file control block). Call INT 21 AH=1A to
- find out whether there is a volume label. If there is, AL returns 0
- and you can change the label using DOS function 17 or delete it
- using DOS function 13. If there's no volume label, function 1A will
- return FF and you can create a label via function 16. Important
- points to notice are that ? wildcards are allowed but * are not; the
- volume label must be space filled not null terminated.
-
- The following MSC 7.0 code worked for me in DOS 5.0; the functions
- it uses have been around since DOS 2.0. The function parameter is 0
- for the current disk, 1 for a:, 2 for b:, etc. It doesn't matter
- what your current directory is; these functions always search the
- root directory for volume labels. (I didn't try to change the
- volume label of any networked drives.)
-
- // Requires DOS.H, STDIO.H, STRING.H
- void vollabel(unsigned char drivenum) {
- static unsigned char extfcb[41], dta[64], status, *newlabel;
- int chars_got = 0;
- #define DOS(buff,func) __asm { __asm mov dx,offset buff \
- __asm mov ax,seg buff __asm push ds __asm mov ds,ax \
- __asm mov ah,func __asm int 21h __asm pop ds \
- __asm mov status,al }
- #define getlabel(buff,prompt) newlabel = buff; \
- memset(newlabel,' ',11); printf(prompt); \
- scanf("%11[^\n]%n", newlabel, &chars_got); \
- if (chars_got < 11) newlabel[chars_got] = ' ';
-
- // Set up the 64-byte transfer area used by function 1A.
- DOS(dta, 1Ah)
- // Set up an extended FCB and search for the volume label.
- memset(extfcb, 0, sizeof extfcb);
- extfcb[0] = 0xFF; // denotes extended FCB
- extfcb[6] = 8; // volume-label attribute bit
- extfcb[7] = drivenum; // 1=A, 2=B, etc.; 0=current drive
- memset(&extfcb[8], '?', 11); // wildcard *.*
- DOS(extfcb,11h)
- if (status == 0) { // DTA contains volume label's FCB
- printf("volume label is %11.11s\n", &dta[8]);
- getlabel(&dta[0x18], "new label (\"delete\" to delete): ");
- if (chars_got == 0)
- printf("label not changed\n");
- else if (strncmp(newlabel,"delete ",11) == 0) {
- DOS(dta,13h)
- printf(status ? "label failed\n" : "label deleted\n");
- }
- else { // user wants to change label
- DOS(dta,17h)
- printf(status ? "label failed\n" : "label changed\n");
- }
- }
- else { // no volume label was found
- printf("disk has no volume label.\n");
- getlabel(&extfcb[8], "new label (<Enter> for none): ");
- if (chars_got > 0) {
- DOS(extfcb,16h)
- printf(status ? "label failed\n" : "label created\n");
- }
- }
- } // end function vollabel
-
- Q409. How can I get the disk serial number?
-
- Use INT 21. AX=6900 gets the serial number; AX=6901 sets it. See
- Ralf Brown's interrupt list, or page 496 of the July 1992 {PC
- Magazine}, for details.
-
- This function also gets and sets the volume label, but it's the
- volume label in the boot record, not the volume label that a DIR
- command displays. See the preceding Q.
-
- Q410. What's the format of .OBJ, .EXE., .COM files?
-
- Please see section 2, "Compile and link".
-
-
- section 5. Serial ports (COM ports)
- ===================================
-
- Q501. How do I set my machine up to use COM3 and COM4?
-
- Unless your machine is fairly old, it's probably already set up.
- After installing the board that contains the extra COM port(s),
- check the I/O addresses in word 0040:0004 or 0040:0006. (In DEBUG,
- type "D 40:4 L4" and remember that every word is displayed low
- byte first, so if you see "03 56" the word is 5603.) If those
- addresses are nonzero, your PC is ready to use the ports and you
- don't need the rest of this answer.
-
- If the I/O address words in the 0040 segment are zero after you've
- installed the I/O board, you need some code to store these values
- into the BIOS data segment:
-
- 0040:0004 word I/O address of COM3
- 0040:0006 word I/O address of COM4
- 0040:0011 byte (bits 3-1): number of serial ports installed
-
- The documentation with your I/O board should tell you the port
- addresses. When you know the proper port addresses, you can add
- code to your program to store them and the number of serial ports
- into the BIOS data area before you open communications. Or you can
- use DEBUG to create a little program to include in your AUTOEXEC.BAT
- file, using this script:
-
- n SET_ADDR.COM <--- or a different name ending in .COM
- a 100
- mov AX,0040
- mov DS,AX
- mov wo [0004],aaaa <--- replace aaaa with COM3 address or 0
- mov wo [0006],ffff <--- replace ffff with COM4 address or 0
- and by [0011],f1
- or by [0011],8 <--- use number of serial ports times 2
- mov AH,0
- int 21
- <--- this line must be blank
- rCX
- 1f
- rBX
- 0
- w
- q
-
- Q502. How do I find the I/O address of a COM port?
-
- Look in the four words beginning at 0040:0000 for COM1 through COM4.
- (The DEBUG command "D 40:0 L8" will do this. Remember that words
- are stored and displayed low byte first, so a word value of 03F8
- will be displayed as F8 03.) If the value is zero, that COM port is
- not installed (or you've got an old BIOS; see the preceding Q). If
- the value is nonzero, it is the I/O address of the transmit/receive
- register for the COM port. Each COM port occupies eight consecutive
- I/O addresses (though only seven are used by many chips).
-
- Here's some C code to find the I/O address:
-
- unsigned ptSel(unsigned comport) {
- unsigned io_addr;
- if (comport >= 1 && comport <= 4) {
- unsigned far *com_addr = (unsigned far *)0x00400000UL;
- io_addr = com_addr[comport-1];
- }
- else
- io_addr = 0;
- return io_addr;
- }
-
- Q503. But aren't the COM ports always at I/O addresses 3F8, 2F8, 3E8,
- and 2E8?
-
- The first two are usually right (though not always); the last two
- are different on many machines.
-
- Q504. How do I configure a COM port and use it to transmit data?
-
- After hearing several recommendations, I looked at Joe Campbell's {C
- Programmer's Guide to Serial Communications}, ISBN 0-672-22584-0,
- and agree that it is excellent. He gives complete details on how
- serial ports work, along with complete programs for doing polled or
- interrupt-driver I/O. The book is quite thick, and none of it looks
- like filler.
-
- If Campbell's book is overkill for you, you'll find a good short
- description of serial I/O in {DOS 5: A Developer's Guide}, ISBN
- 1-55851-177-6, by Al Williams.
-
- You may also want to look at an extended example in Borland's
- TechFax TI445, part of PD1:<MSDOS.TURBO-C> at Simtel. Though
- written by Borland, much of it is applicable to other forms of C,
- and it should give you ideas for other programming languages.
-
- section 6. Other hardware questions and problems
- ================================================
-
- Q601. Which 80x86 CPU is running my program?
-
- According to an article posted by Michael Davidson, Intel's approved
- code for distinguishing among 8086, 80286, 80386, and 80486 and for
- detecting the presence of an 80287 or 80387 is published in the
- Intel's 486SX processor manual (order number 240950-001). You can
- download David Kirschbaum's improved version of this from Simtel as
- PD1:<MSDOS.SYSUTL>CPUID593.ZIP.
-
- According to an article posted by its author, WCPU041.ZIP knows the
- differences between DX and SX varieties of 386 and 486 chips, and
- can also detect a math coprocessor. It's in PD1:<MSDOS.SYSUTL> at
- Simtel.
-
- Q602. How can a C program send control codes to my printer?
-
- If you just fprintf(stdprn, ...), C will translate some of your
- control codes. The way around this is to reopen the printer in
- binary mode:
-
- prn = fopen("PRN", "wb");
-
- You must use a different file handle because stdprn isn't an lvalue.
- By the way, PRN or LPT1 must not be followed by a colon in DOS 5.0.
-
- There's one special case, Ctrl-Z (ASCII 26), the DOS end-of-file
- character. If you try to send an ASCII 26 to your printer, DOS
- simply ignores it. To get around this, you need to reset the
- printer from "cooked" to "raw" mode. Microsoft C users must use int
- 21 function 44, "get/set device information". Turbo C and Borland
- C++ users can use ioctl to accomplish the same thing:
-
- ioctl(fileno(prn), 1, ioctl(fileno(prn),0) & 0xFF | 0x20, 0);
-
- An alternative approach is simply to write the printer output into a
- disk file, then copy the file to the printer with the /B switch.
-
- A third approach is to bypass DOS functions entirely and use the
- BIOS printer functions at INT 17. If you also fprintf(stdprn,...)
- in the same program, you'll need to use fflush( ) to synchronize
- fprintf( )'s buffered output with the BIOS's unbuffered.
-
- By the way, if you've opened the printer in binary mode from a C
- program, remember that outgoing \n won't be translated to carriage
- return/line feed. Depending on your printer, you may need to send
- explicit \n\r sequences.
-
- Q603. How can I redirect printer output to a file?
-
- Please see section 4, "Disks and files", for the answer.
-
- Q604. Which video adapter is installed?
-
- The technique below should work if your BIOS is not too old. It
- uses three functions from INT 10, the BIOS video interrupt. (If
- you're using a Borland language, you may not have to do this the
- hard way. Look for a function called DetectGraph or something
- similar.)
-
- Set AH=12h, AL=0, BL=32h; INT 10h. If AL is 12h, you have a VGA.
- If not, set AH=12h, BL=10h; INT 10h. If BL is 0,1,2,3, you have an
- EGA with 64,128,192,256K memory. If not, set AH=0Fh; INT 10h. If
- AL is 7, you have an MDA (original monochrome adapter) or Hercules;
- if not, you have a CGA.
-
- I've tested this for my VGA and got the right answer; but I can't
- test it for the other equipment types. Please let me know by email
- at brown@ncoast.org if your results vary.
-
- Q605. How do I switch to 43- or 50-line mode?
-
- Download PD1:<MSDOS.SCREEN>VIDMODE.ZIP from Simtel or one of the
- mirror sites. It contains .COM utilities and .ASM source code.
-
- Q606. How can I find the Microsoft mouse position and button status?
-
- Use INT 33 function 3, described in Ralf Brown's interrupt list.
-
- The Windows manual says that the Logitech mouse is compatible with
- the Microsoft one, so I assume the interrupt will work the same.
-